/**
 * 
 */
package com.gosophia.conference.action.starting;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.conferenceManagement.ConferenceTurningAction;
import com.gosophia.conferenceManagement.common.ws.ConferenceHandleWebService;
import com.gosophia.conferenceManagement.scheme.dto.SchemeJobDataDTO;
import com.gosophia.conferenceManagement.starting.dto.ConferenceStartingDTO;
import com.gosophia.springsecurity.UserDetailsImpl;
import com.gosophia.userManagement.dto.UserInfoDTO;
import com.opensymphony.xwork2.ActionContext;

/**
 * 功能：直接发起会议，不进行会议申请
 * 
 * @author zhangdongsheng
 * @since 2011-3-22 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Controller("ConferenceStartingWithNoApplicationAction")
@Scope("prototype")
public class ConferenceStartingWithNoApplicationAction extends
BaseSupportAction {
	private static final long serialVersionUID = 1L;
	private final Logger logger = Logger.getLogger(this.getClass());
	private SchemeJobDataDTO schemeJobDataDTO;
	private String turningActionName;
	@Autowired
	@Qualifier("conferenceHandleWebService")
	private ConferenceHandleWebService conferenceHandleWebService;

	@Override
	@LogRecord(eventAction="会议管理-直接发起会议",eventTarget="conferenceStartingDTO")
	public String _execute() throws Exception {
		// 得到当前用户
		UserDetailsImpl userDetails = (UserDetailsImpl) SecurityContextHolder
				.getContext().getAuthentication().getPrincipal();
		UserInfoDTO creatorDTO = userDetails.getUserAccountDTO().getUserInfoDTO();
		schemeJobDataDTO.setConferenceCreatorDTO(creatorDTO);
		//区分发起的处理动作
		if("jump".equals(turningActionName)){
			schemeJobDataDTO.setTurningAction(ConferenceTurningAction.JUMP_ACTION.getValue());
		}else if("direct_finalized".equals(turningActionName)){
			schemeJobDataDTO.setTurningAction(ConferenceTurningAction.DIRECT_FINALIZED.getValue());
		}else if("getback_finalized".equals(turningActionName)){
			schemeJobDataDTO.setTurningAction(ConferenceTurningAction.GETBACK_FINALIZED.getValue());
		}
		SchemeJobDataDTO schemeJobDataDTOReturn = conferenceHandleWebService.startingConferenceProcessing(schemeJobDataDTO);
		super.getRequestResult().setRsltCode("0");
		super.getRequestResult().setMessage(
				"名称为" + schemeJobDataDTOReturn.getConferenceName() + ", 任务编号为"
						+ schemeJobDataDTOReturn.getMissionCode() + "的会议发起成功");
		ActionContext.getContext().getSession().put("_lastOpResult",
				super.getRequestResult());
		if ("task".equals(this.getFromFlag())) {
			return "task";
		} else {
			return "business";
		}
	}

	public SchemeJobDataDTO getSchemeJobDataDTO() {
		return schemeJobDataDTO;
	}

	public void setSchemeJobDataDTO(SchemeJobDataDTO schemeJobDataDTO) {
		this.schemeJobDataDTO = schemeJobDataDTO;
	}

	public String getTurningActionName() {
		return turningActionName;
	}

	public void setTurningActionName(String turningActionName) {
		this.turningActionName = turningActionName;
	}

	

	
}
